#include "ODebugger.h"

//#include "OExpression.h"
#include "OString.h"

#include <stack>


ODebugger& ODebugger::operator() (){
	std::cout << "\n";
	return *this;
}

ODebugger& ODebugger::operator<< (const char *c){
	std::cout << c;
	return *this;
}

ODebugger& ODebugger::operator<< (bool b){
	if ( b ){ std::cout << "true"; }
	else{ std::cout << "false"; }
	return *this;
}

ODebugger& ODebugger::operator<< (char c){
	std::cout << "\'" << c << "\'";
	return *this;
}

ODebugger& ODebugger::operator<< (short s){
	std::cout << s;
	return *this;
}

ODebugger& ODebugger::operator<< (int i){
	std::cout << i;
	return *this;
}

ODebugger& ODebugger::operator<< (unsigned int i){
	std::cout << i;
	return *this;
}

ODebugger& ODebugger::operator<< (float f){
	std::cout << f;
	return *this;
}

ODebugger& ODebugger::operator<< (double d){
	std::cout << d;
	return *this;
}


OString ODebugger::formatted (int i){
	OString str;
	int tmp = i;
	std::stack<int> st;
	while ( tmp != 0 ){
		st.push( tmp % 10 );
		tmp /= 10;
	}

	while ( ! st.empty() ){
		str += st.top();
		st.pop();
		if ( st.size() % 3 == 0 && st.size() != 0 ){
			str += ",";
		}
	}
	
	return str;
}